import java.awt.EventQueue;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import java.awt.Toolkit;
import java.awt.Font;

public class Hanoi_Tower extends JPanel
{
	private static final long serialVersionUID = 1L;
	private JFrame frmHanoi_Tower;
	/**
	 * Launch the application.
	 */

	/**
	 * Create the application.
	 */
	public Hanoi_Tower() 
	{
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() 
	{
		frmHanoi_Tower = new JFrame();
		frmHanoi_Tower.setIconImage(Toolkit.getDefaultToolkit().getImage("tower_of_hanoi_logo.gif"));
		frmHanoi_Tower.setTitle("Tower of Hanoi");
		frmHanoi_Tower.setBounds(100, 100, 800, 600);
		frmHanoi_Tower.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmHanoi_Tower.setResizable(false);
		
		JMenuBar menuBar = new JMenuBar();
		frmHanoi_Tower.setJMenuBar(menuBar);
		
		JMenu mnGame = new JMenu("Game");
		menuBar.add(mnGame);
		
		JMenuItem mntmNewGame = new JMenuItem("New game");
		mntmNewGame.addActionListener(new ActionListener() 
									{
										public void actionPerformed(ActionEvent arg0) 
										{
											String [] value = new String[]{"3","4","5","6"};
											JOptionPane.showInputDialog(frmHanoi_Tower, "How many disks you want?", "New game", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("tower_of_hanoi_logo.gif"), value, "Number of disks...");
										}
									});
		mnGame.add(mntmNewGame);
		
		JMenuItem mntmExit = new JMenuItem("Exit");
		mntmExit.addActionListener(new ActionListener() 
								{
									public void actionPerformed(ActionEvent arg0) 
									{
										int flag = JOptionPane.showConfirmDialog(frmHanoi_Tower, "Do you really want to exit?", "Exit", JOptionPane.YES_NO_OPTION);
										if (flag == 0)System.exit(0);
										else return;
									}
								});
		mnGame.add(mntmExit);
		
		JMenu mnOther = new JMenu("Other");
		menuBar.add(mnOther);
		
		JMenuItem mntmLeaderboards = new JMenuItem("Leaderboard");
		mnOther.add(mntmLeaderboards);
		
		JMenuItem mntmInformation = new JMenuItem("Information");
		mntmInformation.addActionListener(new ActionListener() 
								{
									public void actionPerformed(ActionEvent e)
									{
										JOptionPane.showMessageDialog(frmHanoi_Tower, "To complete this game, You must move all disks\nfrom first pole to other, and do it in the shortest time.\nRemember that You mustn't put disks on the smaller ones", "INFORMATION", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("Tower_of_Hanoi_4.gif"));
									}
								});
		mnOther.add(mntmInformation);
		
		JMenuItem mntmHel = new JMenuItem("Help");
		mntmHel.addActionListener(new ActionListener()
								{
									public void actionPerformed(ActionEvent e)
									{
										JOptionPane.showMessageDialog(frmHanoi_Tower,"1. To start playing select Game->New Game\n2. To see automatically decision select Other->Example\n3. To see leaderboards select Other->Leaderboard\n4. To exit this application select Game->Exit", "HELP", JOptionPane.QUESTION_MESSAGE);
									}
								});
		mnOther.add(mntmHel);
		
		JMenuItem mntmCopyright = new JMenuItem("Copyright");
		mntmCopyright.addActionListener(new ActionListener()
									{
										public void actionPerformed(ActionEvent e) 
										{
											JOptionPane.showMessageDialog(frmHanoi_Tower, "           Tower of Hanoi\n                 Made by\n         Roman Markelov\n         Alice Seleznyova\n           Anatoliy Nosov\n                 2013(c)", "COPYRIGHT", JOptionPane.INFORMATION_MESSAGE);
										}
									});
		mnOther.add(mntmCopyright);
		frmHanoi_Tower.getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(10, 11, 774, 404);
		frmHanoi_Tower.getContentPane().add(panel);
		
		JRadioButton rdbtnNewRadioButton = new JRadioButton("AUTO");
		rdbtnNewRadioButton.setBounds(20, 422, 109, 23);
		frmHanoi_Tower.getContentPane().add(rdbtnNewRadioButton);
		
		JButton btnNextStep = new JButton("Next step");
		btnNextStep.setBounds(10, 516, 89, 23);
		frmHanoi_Tower.getContentPane().add(btnNextStep);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(196, 426, 121, 35);
		frmHanoi_Tower.getContentPane().add(panel_1);
		
		JLabel lblNewLabel = new JLabel("STEPS");
		lblNewLabel.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		lblNewLabel.setBounds(135, 435, 51, 14);
		frmHanoi_Tower.getContentPane().add(lblNewLabel);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBounds(383, 426, 121, 35);
		frmHanoi_Tower.getContentPane().add(panel_2);
		
		JLabel lblTime = new JLabel("TIME");
		lblTime.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		lblTime.setBounds(327, 435, 46, 14);
		frmHanoi_Tower.getContentPane().add(lblTime);
		
		JPanel panel_4 = new JPanel();
		panel_4.setBounds(663, 426, 121, 35);
		frmHanoi_Tower.getContentPane().add(panel_4);
		
		JLabel lblBestTime = new JLabel("BEST TIME");
		lblBestTime.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		lblBestTime.setBounds(561, 426, 92, 25);
		frmHanoi_Tower.getContentPane().add(lblBestTime);
		
		JLabel lblOptimalSolution = new JLabel("OPTIMAL SOLUTION");
		lblOptimalSolution.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
		lblOptimalSolution.setBounds(327, 472, 173, 14);
		frmHanoi_Tower.getContentPane().add(lblOptimalSolution);
		
		JPanel panel_3 = new JPanel();
		panel_3.setBounds(357, 497, 121, 35);
		frmHanoi_Tower.getContentPane().add(panel_3);
		
		JButton btnStart = new JButton("Start");
		btnStart.setBounds(10, 452, 89, 23);
		frmHanoi_Tower.getContentPane().add(btnStart);
		
		JButton btnStop = new JButton("Stop");
		btnStop.setBounds(10, 482, 89, 23);
		frmHanoi_Tower.getContentPane().add(btnStop);
		
	}
	
	public static void main(String[] args) 
	{
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Hanoi_Tower window = new Hanoi_Tower();
					window.frmHanoi_Tower.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
}